package stack.testStack;

/**
 * 对于数组栈的简单测试
 */

import stack.stackDefine.MyArrayListStack;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        MyArrayListStack<Integer> stack = new MyArrayListStack<>();
        String key = "";
        boolean loop = true;
        Scanner scanner = new Scanner(System.in);
        while(loop){
            System.out.println("show:显示栈");
            System.out.println("exit:推出");
            System.out.println("push:添加数据到栈");
            System.out.println("pop:从栈取出数据");
            System.out.println("cap:显示容量");
            System.out.println("请输入你的选择");

            key = scanner.next();
            switch (key){
                case "cap":
                    System.out.println(stack.getCapacity());
                    break;
                case "show":
                    stack.display();
                    break;
                case "exit":
                    scanner.close();
                    loop = false;
                    break;
                case "push":
                    System.out.println("input");
                    int value = scanner.nextInt();
                    stack.push(value);
                    break;
                case "pop":
                    try{
                        int res = stack.pop();
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    break;
                default:
                    break;
            }
        }
    }
}
